#include "mylabel.h"

MyLabel::MyLabel()
{

}

MyLabel::MyLabel(QWidget *parent):QLabel(parent)
{

}

void MyLabel::enterEvent(QEvent *event)
{
    (void)event;
    qDebug()<<"鼠标进入事件";
    this->setText("鼠标进入事件");
}

void MyLabel::leaveEvent(QEvent *event)
{
    (void)event;
    qDebug()<<"鼠标离开事件";
    this->setText("鼠标离开事件");
}

void MyLabel::mousePressEvent(QMouseEvent *event)
{
    QString str=QString("鼠标按下事件：x = %1，y = %2").arg(event->x()).arg(event->y());
    this->setText(str);
    qDebug()<<"鼠标按下事件";
}

void MyLabel::mouseReleaseEvent(QMouseEvent *event)
{
    //QString str=QString("鼠标松开事件：x = %1，y = %2").arg(event->x()).arg(event->y());
    //屏幕左上角为原点
    QString str=QString("鼠标松开事件：x = %1，y = %2").arg(event->globalX()).arg(event->globalY());
    this->setText(str);
    qDebug()<<"鼠标松开事件";
}

void MyLabel::mouseDoubleClickEvent(QMouseEvent *event)
{
    QString str=QString("鼠标双击事件：x = %1，y = %2").arg(event->x()).arg(event->y());
    this->setText(str);
    qDebug()<<"鼠标双击事件";
}


